package fpt.edu.vn.action;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import fpt.edu.vn.dao.UsersDao;
import fpt.edu.vn.model.Locations;
import fpt.edu.vn.model.Locationtypes;
import fpt.edu.vn.model.Provinces;
import fpt.edu.vn.model.Roles;
import fpt.edu.vn.model.Users;

/* 
 * AdminUserLoadAction.java 
 *  
 * 0.1
 * 
 * 10/15/2012 
 *  
 * Copyright notice 
 *  
 * Modification Logs: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  -------------------------------------------------------- 
 *  15-Oct-2012  ThuongND    Create new 
 */
public class AdminUserLoadAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private String email;

	private String Username;
	private int usersId;

	private String displayName;

	private Date createDate;

	private Date lastLoginDate;

	private int isBanner;
	private int news_per_page;
	private int roleId;
	private int sizelist;
	private List<Object> lstusers;
	private List<Roles> lstRoles;
	private UsersDao usernewdao = new UsersDao();
	// For SessionAware
	Map<String, Object> session;
	
	public String execute() {
		session = ActionContext.getContext().getSession();
		if (session.containsKey("userRoleIdss")) {
			email = (String) session.get("emailss");
			int isAdmin = (Integer) session.get("userRoleIdss");
			if (isAdmin == 1) {
				
				// get district
				lstusers = usernewdao.listuser();
				sizelist =lstusers.size(); 
				lstRoles = usernewdao.listRoles();
				news_per_page =50;
				return SUCCESS;
			} 
		}
		return ERROR;

	}

	public Date getSysdate() {
		Date date = new Date();
		return date;
	}

	public String getStrDate() {
		String curdate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
				.format(Calendar.getInstance().getTime());
		return curdate;
	}
	
	public int getNews_per_page() {
		return news_per_page;
	}

	public void setNews_per_page(int news_per_page) {
		this.news_per_page = news_per_page;
	}

	public int getUsersId() {
		return usersId;
	}
	
	public List<Roles> getLstRoles() {
		return lstRoles;
	}
	public void setLstRoles(List<Roles> lstRoles) {
		this.lstRoles = lstRoles;
	}
	public void setUsersId(int usersId) {
		this.usersId = usersId;
	}
	
	public int getSizelist() {
		return sizelist;
	}

	public void setSizelist(int sizelist) {
		this.sizelist = sizelist;
	}

	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getLastLoginDate() {
		return lastLoginDate;
	}

	public void setLastLoginDate(Date lastLoginDate) {
		this.lastLoginDate = lastLoginDate;
	}

	public int getIsBanner() {
		return isBanner;
	}

	public void setIsBanner(int isBanner) {
		this.isBanner = isBanner;
	}

	public int getRoleId() {
		return roleId;
	}

	public void setRoleId(int roleId) {
		this.roleId = roleId;
	}

	public List<Object> getLstusers() {
		return lstusers;
	}

	public void setLstusers(List<Object> lstusers) {
		this.lstusers = lstusers;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getUsername() {
		return Username;
	}

	public void setUsername(String username) {
		Username = username;
	}
}
